import com.alibaba.druid.pool.DruidDataSource;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import student.systemDB.Dao.UserDaoImpl;
import student.systemDB.bean.User;

import java.util.List;

public class DataSourceTest {
@Test
    public void test() {

    DruidDataSource druidDataSource = new DruidDataSource();
    druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
    druidDataSource.setUrl("jdbc:mysql://localhost:3306/db_student");
    druidDataSource.setUsername("root");
    druidDataSource.setPassword("123456");

    System.out.println(druidDataSource);

    }
    @Test
    public void test2(){
        ClassPathXmlApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("student.xml");
        UserDaoImpl userDao = applicationContext.getBean("userDaoImpl", UserDaoImpl.class);
        List<User> users = userDao.selectAll();
        for (User user : users) {
            System.out.println(user);
        }
    }

}
